using System;
using System.IO;
using System.Linq;
using Microsoft.Xna.Framework;
using System.Collections.Generic;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input.Touch;
using Microsoft.Xna.Framework.GamerServices;
using System.IO.IsolatedStorage;
using System.IO;

namespace ebookreader
{
    public class EbookReader : Microsoft.Xna.Framework.Game
    {
        public static bool isTrial;

        public GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        
        public EbookReader()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            //Guide.SimulateTrialMode = true;
            isTrial = Guide.IsTrialMode;
            
            //graphics.SetPortraitOrientation();
            graphics.SetLandscapeLeftOrientation();
            graphics.IsFullScreen = true;
            //TargetElapsedTime = TimeSpan.FromSeconds(1 / 30.0f);
        }

        public static State state;
        protected override void Initialize()
        {

            spriteBatch = new SpriteBatch(GraphicsDevice);
            Services.AddService(typeof(SpriteBatch), spriteBatch);
            Services.AddService(typeof(GraphicsDeviceManager), graphics);

            state = State.loadSate();
            Services.AddService(typeof(State), state);
            //Exiting += new EventHandler<EventArgs>((a, b) => 
            //{ state.SaveState(); });

            ScreenManager.CleanupComponents(this);

            Components.Add(new LogoScreen(this,"Definitivo/vst_logo", graphics));
            DownloadBook.loadBooksList();



            base.Initialize();
        }

        protected override void Update(GameTime gameTime)
        {
            //if (GamePad.GetState(PlayerIndex.One).IsButtonDown(Buttons.Back))
            //    this.Exit();

            base.Update(gameTime);
        }

        public void PDraw(GameTime gameTime)
        {
            Draw(gameTime);
        }
               
              
    }
}
